package com.hr.mes.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hr.mes.dto.Page;
import com.hr.mes.entity.Release;
import com.hr.mes.mapper.ReleaseMapper;
import com.hr.mes.service.ReleaseService;
import com.hr.mes.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ReleaseServiceImpl implements ReleaseService {

    @Autowired
    private ReleaseMapper releaseMapper;

    @Override
    public void addRelease(Release release) {
        releaseMapper.addRelease(release);
    }

    @Override
    public Page<Release> getReleaseList(Integer pageNo, Integer pageSize) {
        List<Release> releaseList = releaseMapper.getReleaseList();
        PageHelper.startPage(pageNo, pageSize);
        PageInfo<Release> pageInfo = new PageInfo<>(releaseList);
        Page<Release> page = PageUtil.ConvertPageInfoToPage(pageInfo);
        PageHelper.clearPage();
        return page;
    }
}
